package org.example.collect;

import java.util.HashMap;
import java.util.Map;

public class CustomMap {

    private HashMap<String,Object> map;

    public CustomMap(String key,Object value){
        this.map=new HashMap<String ,Object>();
        map.put(key,value);
    }

    public void print(boolean isToString){
        if(!isToString){
            System.out.println("元素包括：");
            for(Map.Entry<String,Object> entry:map.entrySet()){
                System.out.println(entry.getKey()+":"+entry.getValue());
            }
            System.out.println("\r\n----------");

        }
        else{
            System.out.println("元素包括：");
            System.out.print(map.toString());
            System.out.println("\r\n----------");
        }
    }

    public void remove(String key){
        map.remove(key);
    }

    public void clear(){
        map.clear();
    }

    public void put(String key,Object value){
        map.put(key, value);
    }

    public Object get(String key){
        return map.get(key);
    }

    public HashMap<String, Object> getMap() {
        return map;
    }

    public void setMap(HashMap<String, Object> map) {
        this.map = map;
    }
}
